home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / unix / pipe.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  853b  |  44 lines

  1.  
  2. /*
  3.  *  UNIX/PIPE.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <exec/types.h>
  11. #include <clib/exec_protos.h>
  12.  
  13. #include <stdio.h>
  14. #include <fcntl.h>
  15. #include <time.h>
  16.  
  17. int
  18. pipe(fda)
  19. int *fda;
  20. {
  21.     static short Cnt;
  22.     char baseName[64];
  23.     char buf[64];
  24.  
  25.     sprintf(baseName, "FIFO:%07lx.%06lx.%04lx", FindTask(NULL) >> 4, time(NULL), Cnt++);
  26.  
  27.     sprintf(buf, "%s/r", baseName);
  28.     fda[0] = open(buf, O_CREAT|O_TRUNC|O_RDONLY|O_BINARY);
  29.  
  30.     sprintf(buf, "%s/wmeK", baseName);
  31.     fda[1] = open(buf, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY);
  32.  
  33.     if (fda[0] < 0 || fda[1] < 0) {
  34.     if (fda[0] >= 0)
  35.         close(fda[0]);
  36.     if (fda[1] >= 0)
  37.         close(fda[1]);
  38.     fda[0] = fda[1] = -1;
  39.     return(-1);
  40.     }
  41.     return(0);
  42. }
  43.  
  44.